资源更新

master
youahng 3 months ago committed by yh
parent 2a42c9de00
commit e8117601cc
  1. 59
      src/main/java/com/teaching/backend/constant/ViewContentTypeEnum.java
  2. 2
      src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java
  3. 3
      src/main/java/com/teaching/backend/model/dto/resource/ResourceUploadDto.java
  4. 4
      src/main/java/com/teaching/backend/model/entity/resource/Resources.java
  5. 1
      src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java
  6. 1
      src/main/java/com/teaching/backend/utils/MinioUtils.java

@ -1,5 +1,6 @@
package com.teaching.backend.constant;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
@ -11,24 +12,25 @@ import java.util.Map;
* @Description:
*/
public enum ViewContentTypeEnum {
DEFAULT("default","application/octet-stream"),
PNG("png", "image/png"),
JPEG("jpeg", "image/jpeg"),
JPG("jpg", "image/jpeg"),
GIF("gif", "image/gif"),
WBMP("wbmp", "image/vnd.wap.wbmp"),
TIFF("tiff", "image/tiff"),
JFIF("jfif", "image/jpeg"),
TIF("tif", "image/tiff"),
FAX("fax", "image/fax"),
JPE("jpe", "image/jpeg"),
NET("net", "image/pnetvue"),
RP("rp", "image/vnd.rn-realpix"),
ICO("ico", "image/x-icon");
DEFAULT("default","application/octet-stream",0),
PNG("png", "image/png",1),
JPEG("jpeg", "image/jpeg",2),
JPG("jpg", "image/jpeg",3),
GIF("gif", "image/gif",4),
WBMP("wbmp", "image/vnd.wap.wbmp", 5),
TIFF("tiff", "image/tiff", 6),
JFIF("jfif", "image/jpeg", 7),
TIF("tif", "image/tiff", 8),
FAX("fax", "image/fax", 9),
JPE("jpe", "image/jpeg", 10),
NET("net", "image/pnetvue", 11),
RP("rp", "image/vnd.rn-realpix", 12),
ICO("ico", "image/x-icon", 13);
private String prefix;
private String type;
private Integer num;
private static final Map<String, ViewContentTypeEnum> ENUM_MAP = new HashMap<>();
@ -59,9 +61,10 @@ public enum ViewContentTypeEnum {
return DEFAULT.getType();
}
ViewContentTypeEnum(String prefix, String type) {
ViewContentTypeEnum(String prefix, String type, int num) {
this.prefix = prefix;
this.type = type;
this.num = num;
}
public String getPrefix() {
@ -71,4 +74,30 @@ public enum ViewContentTypeEnum {
public String getType() {
return type;
}
public Integer getNum() {
return num;
}
public static Integer getNumByPrefix(String prefix) {
ViewContentTypeEnum viewContentTypeEnum = ENUM_MAP.get(prefix);
if (viewContentTypeEnum == null) {
return 0;
}
return viewContentTypeEnum.getNum();
}
public static Integer getNumByName(String prefix) {
if(StringUtils.isEmpty(prefix)){
return DEFAULT.getNum();
}
prefix = prefix.substring(prefix.lastIndexOf(".") + 1);
Integer num = getNumByPrefix(prefix);
if (num != null) {
return num;
}
return DEFAULT.getNum();
}
}

@ -42,7 +42,7 @@ public interface ResourcesRepository extends Neo4jRepository<Resources, Long> {
Set<Resources> queryResourcesByChapterId(Long chapterId);
//查询二级节点下资源
@Query("MATCH (p:Know)-[:FatherAndSon]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $KnowId RETURN m")
@Query("MATCh (p:Know)-[*0..1]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $KnowId RETURN m")
Set<Resources> queryBesidesKnowToResources(Long KnowId);

@ -18,5 +18,8 @@ public class ResourceUploadDto {
private String name;
private Integer num;
private String objectName;
}

@ -25,6 +25,10 @@ public class Resources {
@Property
private Integer status;
@Property
private Integer type;
@Property
private String url;
}

@ -78,6 +78,7 @@ public class ResourceServiceImpl implements ResourceService {
//添加到图数据库中
Resources resource = new Resources();
resource.setType(resourceUploadDto.getNum());
resource.setName(objectName);
resource.setStatus(0);
resource.setUrl(url);

@ -92,6 +92,7 @@ public class MinioUtils {
minioUploadDto.setName(filename);
minioUploadDto.setUrl(ENDPOINT + "/" + BUCKET_NAME + "/" + objectName);
minioUploadDto.setObjectName(objectName);
minioUploadDto.setNum(ViewContentTypeEnum.DEFAULT.getNumByName(objectName));
} catch (Exception e) {
e.printStackTrace();
LOGGER.info("上传发生错误: {}!", e.getMessage());

Loading…
Cancel
Save