zbj//1.资源管理 上传资源
This commit is contained in:
@@ -67,4 +67,9 @@ public interface OssPath {
|
||||
* 装置模板
|
||||
*/
|
||||
String DEV_MODEL = "algorithm/devModel/";
|
||||
|
||||
/***
|
||||
* 资源管理文件
|
||||
*/
|
||||
String RESOURCEADMINISTRATION = "resourceAdministration/";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.system.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author zbj
|
||||
* @since 2023-04-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("pqs_resinformation")
|
||||
public class Resinformation {
|
||||
|
||||
/**
|
||||
* 资源序号
|
||||
*/
|
||||
@TableField(value = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 资源名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 资源描述
|
||||
*/
|
||||
@TableField(value = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 资源路径
|
||||
*/
|
||||
@TableField(value = "res_url")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 数据更新人ID(外键user表)
|
||||
*/
|
||||
@TableField(value = "updateuser")
|
||||
private String updateUser;
|
||||
|
||||
/**
|
||||
* 数据更新时间
|
||||
*/
|
||||
@TableField(value = "updatetime")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 数据状态(0: 删除; 1: 正常)
|
||||
*/
|
||||
@TableField(value = "state")
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 系统类型Guid
|
||||
*/
|
||||
@TableField(value = "systype")
|
||||
private String systemType;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -52,6 +52,12 @@
|
||||
<artifactId>okio</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.system.service.IResourceAdministrationService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: zbj
|
||||
* @date: 2023/04/17
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "资源管理")
|
||||
@RestController
|
||||
@RequestMapping("/resourceAdministration")
|
||||
@RequiredArgsConstructor
|
||||
public class ResourceAdministrationController extends BaseController {
|
||||
|
||||
private final IResourceAdministrationService iResourceAdministrationService;
|
||||
|
||||
/**
|
||||
* 上传资源
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/uploadFile")
|
||||
@ApiOperation("上传资源")
|
||||
public HttpResult<Boolean> uploadFile(@ApiParam(value = "文件", required = true)@RequestPart("multipartFile") MultipartFile multipartFile,
|
||||
@ApiParam(value = "资源名称", required = true)String name,
|
||||
@ApiParam(value = "资源类型", required = true) String type,
|
||||
@ApiParam(value = "资源描述", required = false)String describe,
|
||||
@ApiParam(value = "系统类型Guid", required = true) String systemType) {
|
||||
String methodDescribe = getMethodDescribe("uploadFile");
|
||||
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, name, type, describe, systemType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.Resinformation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: zbj
|
||||
* @date: 2023/04/17
|
||||
*/
|
||||
@Mapper
|
||||
public interface ResourceAdministrationMapper extends BaseMapper<Resinformation> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?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="com.njcn.system.mapper.ResourceAdministrationMapper">
|
||||
</mapper>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.po.Resinformation;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: zbj
|
||||
* @date: 2023/04/17
|
||||
*/
|
||||
public interface IResourceAdministrationService extends IService<Resinformation> {
|
||||
|
||||
Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe,String systemType);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.mapper.ResourceAdministrationMapper;
|
||||
import com.njcn.system.pojo.po.Resinformation;
|
||||
import com.njcn.system.service.IResourceAdministrationService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: zbj
|
||||
* @date: 2023/04/17
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdministrationMapper, Resinformation> implements IResourceAdministrationService {
|
||||
|
||||
private final ResourceAdministrationMapper resourceAdministrationMapper;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Override
|
||||
public Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe, String systemType) {
|
||||
//通过封装好的文件工具类来传入文件和文件夹名称来获取文件路径
|
||||
String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION);
|
||||
//创建对象
|
||||
Resinformation resinformation = new Resinformation();
|
||||
resinformation.setName(name);
|
||||
if (Objects.nonNull(describe)) {
|
||||
resinformation.setDescription(describe);
|
||||
}
|
||||
resinformation.setUrl(url);
|
||||
//获取用户id
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
//String userIndex = "123456";
|
||||
resinformation.setUpdateUser(userIndex);
|
||||
resinformation.setUpdateTime(LocalDateTime.now());
|
||||
resinformation.setState(1);
|
||||
resinformation.setSystemType(systemType);
|
||||
resinformation.setType(type);
|
||||
return this.save(resinformation);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user