mirror of https://gitee.com/stylefeng/roses
commit
e2f1b04ce3
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
|
@ -5,37 +29,51 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb文件管理API
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-30 11:06
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
public interface MongoFileApi<T,ID> {
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
* @param file
|
||||
* @return
|
||||
*
|
||||
* @param file 上传的文件对象
|
||||
* @return 返回数据结果
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
T saveFile(MultipartFile file);
|
||||
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param id
|
||||
* 根据id删除文件
|
||||
*
|
||||
* @param id 集合id
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
void removeFile(ID id);
|
||||
|
||||
/**
|
||||
* 根据id获取文件
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param id 集合id
|
||||
* @return 返回查询到数据的Optional
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
Optional<T> getFileById(ID id);
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取文件
|
||||
* 分页获取文件列表
|
||||
*
|
||||
* @param fileDocument 查询条件
|
||||
* @return
|
||||
* @return 返回查询文件的分页结果
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
PageResult<T> getFilesByPage(T fileDocument);
|
||||
|
||||
|
|
|
@ -1,46 +1,85 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.api;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb数据存储的api,适用于存map类型数据,存储在guns_map集合中
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
public interface MongodbApi<T,ID> {
|
||||
|
||||
/**
|
||||
* 新增操作
|
||||
* @param gunsMapEntity
|
||||
* @return
|
||||
* 新增数据
|
||||
*
|
||||
* @param gunsMapEntity 数据存储的参数
|
||||
* @return 返回数据结果
|
||||
* @author huziyang
|
||||
* @date 2020/10/27 17:38
|
||||
*/
|
||||
T insert(T gunsMapEntity);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param gunsMapEntity
|
||||
* @return
|
||||
* 修改数据
|
||||
*
|
||||
* @param gunsMapEntity 数据存储的参数
|
||||
* @return 返回数据结果
|
||||
* @author huziyang
|
||||
* @date 2020/10/27 17:38
|
||||
*/
|
||||
T update(T gunsMapEntity);
|
||||
|
||||
/**
|
||||
* 根据id删除
|
||||
* @param id
|
||||
*
|
||||
* @param id 集合id
|
||||
* @author huziyang
|
||||
* @date 2020/10/27 17:38
|
||||
*/
|
||||
void deleteById(ID id);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param id 集合id
|
||||
* @return 返回查询到数据的Optional
|
||||
* @author huziyang
|
||||
* @date 2020/10/27 17:38
|
||||
*/
|
||||
Optional<T> findById(ID id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
* @return
|
||||
* 查询所有数据
|
||||
*
|
||||
* @return 返回所有数据列表
|
||||
* @author huziyang
|
||||
* @date 2020/10/27 17:38
|
||||
*/
|
||||
List<T> findAll();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,34 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.api.constants;
|
||||
|
||||
/**
|
||||
* Mongodb模块的常量
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
public interface MongodbConstants {
|
||||
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.api.exception;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.api.constants.MongodbConstants;
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.integration.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
|
@ -5,14 +29,22 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
|||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* MongoDB文件管理界面渲染控制器
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-30 15:21
|
||||
* @date 2021/03/30 15:21
|
||||
*/
|
||||
@Controller
|
||||
@ApiResource(name = "MongoDB文件管理界面渲染控制器")
|
||||
public class ModelViewController {
|
||||
|
||||
|
||||
/**
|
||||
* 文件管理视图
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 15:21
|
||||
*/
|
||||
@GetResource(name = "Mongodb文件列表视图", path = "/view/mongodb/file")
|
||||
public String mongodbFile() {
|
||||
return "/modular/mongodb/fileList.html";
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.integration.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.api.MongoFileApi;
|
||||
|
@ -14,15 +38,16 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb文件管理接口控制器
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-31 17:28
|
||||
* @date 2021/03/31 17:28
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "Mongodb文件接口控制器")
|
||||
|
@ -31,22 +56,46 @@ public class MongoFileController {
|
|||
@Resource
|
||||
private MongoFileApi<MongoFileEntity,String> mongoFileApi;
|
||||
|
||||
/**
|
||||
* 新增文件
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/31 17:28
|
||||
*/
|
||||
@PostResource(name = "Mongodb文件新增", path = "/view/mongodb/file/add")
|
||||
public ResponseData mongodbFileAdd(@RequestPart("file") MultipartFile file) {
|
||||
return new SuccessResponseData(mongoFileApi.saveFile(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除文件
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/31 17:28
|
||||
*/
|
||||
@PostResource(name = "Mongodb文件删除", path = "/view/mongodb/file/del")
|
||||
public ResponseData mongodbFileDel(@RequestParam String id) {
|
||||
mongoFileApi.removeFile(id);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页文件列表
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/31 17:28
|
||||
*/
|
||||
@GetResource(name = "Mongodb文件列表", path = "/view/mongodb/file/list")
|
||||
public ResponseData mongodbFileList(MongoFileEntity mongoFileEntity) {
|
||||
return new SuccessResponseData(mongoFileApi.getFilesByPage(mongoFileEntity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id下载文件
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/31 17:28
|
||||
*/
|
||||
@GetResource(name = "Mongodb文件下载", path = "/view/mongodb/file/down")
|
||||
public ResponseEntity mongodbFileDown(@RequestParam String id) throws UnsupportedEncodingException {
|
||||
Optional<MongoFileEntity> file = mongoFileApi.getFileById(id);
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.file.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
|
@ -11,8 +35,10 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Mongodb 文件存储集合实体
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-26 17:23
|
||||
* @date 2021/03/26 17:23
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.file.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.file.entity.MongoFileEntity;
|
||||
|
@ -5,8 +29,10 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
/**
|
||||
* Mongodb 文件存储Mapper
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-26 17:27
|
||||
* @date 2021/03/26 17:27
|
||||
*/
|
||||
@Configuration
|
||||
public interface MongoFileMapper extends MongoRepository<MongoFileEntity,String> {
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.file.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
|
@ -6,37 +30,51 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb 文件存储接口
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-26 17:28
|
||||
* @date 2021/03/26 17:28
|
||||
*/
|
||||
public interface MongoFileService {
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
* @param file
|
||||
* @return
|
||||
*
|
||||
* @param file 上传的文件对象
|
||||
* @return 返回数据结果
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
MongoFileEntity saveFile(MultipartFile file);
|
||||
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param id
|
||||
* 根据id删除文件
|
||||
*
|
||||
* @param id 集合id
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
void removeFile(String id);
|
||||
|
||||
/**
|
||||
* 根据id获取文件
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param id 集合id
|
||||
* @return 返回查询到数据的Optional
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
Optional<MongoFileEntity> getFileById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取文件
|
||||
* 分页获取文件列表
|
||||
*
|
||||
* @param fileDocument 查询条件
|
||||
* @return
|
||||
* @return 返回查询文件的分页结果
|
||||
* @author huziyang
|
||||
* @date 2021/03/30 11:06
|
||||
*/
|
||||
PageResult<MongoFileEntity> getFilesByPage(MongoFileEntity fileDocument);
|
||||
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.file.service.impl;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
|
@ -28,8 +52,10 @@ import java.util.Date;
|
|||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb 文件存储实现类
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-26 17:29
|
||||
* @date 2021/03/26 17:29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -9,8 +33,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mongodb 数据存储集合实体
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.entity.GunsMapEntity;
|
||||
|
@ -5,8 +29,10 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
/**
|
||||
* Mongodb 数据存储mapper
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
@Configuration
|
||||
public interface GunsMapRepository extends MongoRepository<GunsMapEntity,String> {
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.entity.GunsMapEntity;
|
||||
|
@ -6,41 +30,58 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb 数据存储接口
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
public interface GunsMapService {
|
||||
|
||||
/**
|
||||
* 新增操作
|
||||
* @param gunsMapEntity
|
||||
* @return
|
||||
* 新增数据
|
||||
*
|
||||
* @param gunsMapEntity 数据参数
|
||||
* @return 返回新增数据结果
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
GunsMapEntity insert(GunsMapEntity gunsMapEntity);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param gunsMapEntity
|
||||
* @return
|
||||
* 修改数据
|
||||
*
|
||||
* @param gunsMapEntity 数据参数
|
||||
* @return 返回修改数据结果
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
GunsMapEntity update(GunsMapEntity gunsMapEntity);
|
||||
|
||||
/**
|
||||
* 根据id删除
|
||||
* @param id
|
||||
*
|
||||
* @param id 集合id
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param id 集合id
|
||||
* @return 返回查询到数据的Optional
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
Optional<GunsMapEntity> findById(String id);
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
* @return
|
||||
* 查询所有集合中数据
|
||||
*
|
||||
* @return 返回所有数据集合
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
List<GunsMapEntity> findAll();
|
||||
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.service.impl;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.api.MongodbApi;
|
||||
|
@ -10,8 +34,10 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mongodb 数据存储实现类
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
@Service
|
||||
public class GunsMapServiceImpl implements GunsMapService, MongodbApi<GunsMapEntity,String> {
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.mongodb.starter;
|
||||
|
||||
import cn.stylefeng.roses.kernel.mongodb.api.MongoFileApi;
|
||||
|
@ -8,19 +32,32 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Mongodb模块自动配置
|
||||
*
|
||||
* @author huziyang
|
||||
* @create 2021-03-20 16:24
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
@Configuration
|
||||
public class GunsMongodbAutoConfiguration {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Mongodb 数据存储
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
@Bean
|
||||
public MongodbApi mongodbApi() {
|
||||
return new GunsMapServiceImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mongodb 文件管理
|
||||
*
|
||||
* @author huziyang
|
||||
* @date 2021/03/20 16:24
|
||||
*/
|
||||
@Bean
|
||||
public MongoFileApi mongoFileApi() {
|
||||
return new MongoFileServiceImpl();
|
||||
|
|
Loading…
Reference in New Issue