mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-24 05:02:43 +08:00
资源分类可选
This commit is contained in:
parent
b4db9d67b2
commit
9aa63dba66
@ -42,11 +42,17 @@ public class ResourceController {
|
||||
String sortField = MapUtils.getString(params, "sort_field");
|
||||
String sortAlgo = MapUtils.getString(params, "sort_algo");
|
||||
String name = MapUtils.getString(params, "name");
|
||||
String type = MapUtils.getString(params, "type");
|
||||
String categoryIdsStr = MapUtils.getString(params, "category_ids");
|
||||
|
||||
if (type == null || type.trim().length() == 0) {
|
||||
return JsonResponse.error("请选择资源类型");
|
||||
}
|
||||
|
||||
ResourcePaginateFilter filter = new ResourcePaginateFilter();
|
||||
filter.setSortAlgo(sortAlgo);
|
||||
filter.setSortField(sortField);
|
||||
filter.setType(type);
|
||||
if (name != null && name.length() > 0) {
|
||||
filter.setName(name);
|
||||
}
|
||||
@ -96,7 +102,7 @@ public class ResourceController {
|
||||
}
|
||||
}
|
||||
|
||||
Resource res = resourceService.create(categoryId, req.getName(), extension, req.getSize(), disk, req.getFileId(), req.getPath(), req.getUrl());
|
||||
Resource res = resourceService.create(categoryId, type, req.getName(), extension, req.getSize(), disk, req.getFileId(), req.getPath(), req.getUrl());
|
||||
|
||||
if (isVideoType) {
|
||||
resourceVideoService.create(res.getId(), duration);
|
||||
|
@ -53,8 +53,8 @@ public class UploadController {
|
||||
return JsonResponse.error("格式不支持");
|
||||
}
|
||||
|
||||
Integer categoryId = MapUtils.getInteger(params, "category_id", 0);
|
||||
if (resourceCategoryService.getById(categoryId) == null) {
|
||||
Integer categoryId = MapUtils.getInteger(params, "category_id");
|
||||
if (categoryId != null && !categoryId.equals(0) && resourceCategoryService.getById(categoryId) == null) {
|
||||
return JsonResponse.error("分类不存在");
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class UploadController {
|
||||
|
||||
String url = minioConfig.getDomain() + minioConfig.getBucket() + "/" + savePath;
|
||||
|
||||
Resource res = resourceService.create(categoryId, oldFilename, ext, file.getSize(), "minio", "", savePath, url);
|
||||
Resource res = resourceService.create(categoryId, BackendConstant.RESOURCE_TYPE_IMAGE, oldFilename, ext, file.getSize(), "minio", "", savePath, url);
|
||||
return JsonResponse.data(res);
|
||||
} catch (Exception e) {
|
||||
return JsonResponse.error("系统错误");
|
||||
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@ -12,17 +11,23 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName resources
|
||||
*/
|
||||
@TableName(value = "resources")
|
||||
@TableName(value ="resources")
|
||||
@Data
|
||||
public class Resource implements Serializable {
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
@ -65,6 +70,9 @@ public class Resource implements Serializable {
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty("created_at")
|
||||
private Date createdAt;
|
||||
|
||||
@ -84,15 +92,16 @@ public class Resource implements Serializable {
|
||||
}
|
||||
Resource other = (Resource) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getCategoryId() == null ? other.getCategoryId() == null : this.getCategoryId().equals(other.getCategoryId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getExtension() == null ? other.getExtension() == null : this.getExtension().equals(other.getExtension()))
|
||||
&& (this.getSize() == null ? other.getSize() == null : this.getSize().equals(other.getSize()))
|
||||
&& (this.getDisk() == null ? other.getDisk() == null : this.getDisk().equals(other.getDisk()))
|
||||
&& (this.getFileId() == null ? other.getFileId() == null : this.getFileId().equals(other.getFileId()))
|
||||
&& (this.getPath() == null ? other.getPath() == null : this.getPath().equals(other.getPath()))
|
||||
&& (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
|
||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
|
||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
|
||||
&& (this.getCategoryId() == null ? other.getCategoryId() == null : this.getCategoryId().equals(other.getCategoryId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getExtension() == null ? other.getExtension() == null : this.getExtension().equals(other.getExtension()))
|
||||
&& (this.getSize() == null ? other.getSize() == null : this.getSize().equals(other.getSize()))
|
||||
&& (this.getDisk() == null ? other.getDisk() == null : this.getDisk().equals(other.getDisk()))
|
||||
&& (this.getFileId() == null ? other.getFileId() == null : this.getFileId().equals(other.getFileId()))
|
||||
&& (this.getPath() == null ? other.getPath() == null : this.getPath().equals(other.getPath()))
|
||||
&& (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
|
||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,6 +109,7 @@ public class Resource implements Serializable {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
||||
result = prime * result + ((getCategoryId() == null) ? 0 : getCategoryId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getExtension() == null) ? 0 : getExtension().hashCode());
|
||||
@ -119,6 +129,7 @@ public class Resource implements Serializable {
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", type=").append(type);
|
||||
sb.append(", categoryId=").append(categoryId);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", extension=").append(extension);
|
||||
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resources】的数据库操作Mapper
|
||||
* @createDate 2023-02-23 10:50:26
|
||||
* @createDate 2023-03-06 10:06:57
|
||||
* @Entity xyz.playedu.api.domain.Resource
|
||||
*/
|
||||
@Mapper
|
||||
|
@ -14,6 +14,6 @@ public interface ResourceService extends IService<Resource> {
|
||||
|
||||
PaginationResult<Resource> paginate(int page, int size, ResourcePaginateFilter filter);
|
||||
|
||||
Resource create(Integer categoryId, String filename, String ext, Long size, String disk, String fileId, String path, String url);
|
||||
Resource create(Integer categoryId, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url);
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
if (filter.getExtension() != null) {
|
||||
wrapper.eq("extension", filter.getExtension());
|
||||
}
|
||||
if (filter.getType() != null) {
|
||||
wrapper.eq("type", filter.getType());
|
||||
}
|
||||
if (filter.getCategoryIds() != null && filter.getCategoryIds().length > 0) {
|
||||
wrapper.in("category_id", Arrays.asList(filter.getCategoryIds()));
|
||||
}
|
||||
@ -65,8 +68,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource create(Integer categoryId, String filename, String ext, Long size, String disk, String fileId, String path, String url) {
|
||||
public Resource create(Integer categoryId, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url) {
|
||||
Resource resource = new Resource();
|
||||
resource.setType(type);
|
||||
resource.setCategoryId(categoryId);
|
||||
resource.setName(filename);
|
||||
resource.setExtension(ext);
|
||||
|
@ -21,4 +21,6 @@ public class ResourcePaginateFilter {
|
||||
|
||||
private Integer[] categoryIds;
|
||||
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,8 @@
|
||||
<mapper namespace="xyz.playedu.api.mapper.ResourceMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="xyz.playedu.api.domain.Resource">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="type" column="type" jdbcType="VARCHAR"/>
|
||||
<result property="categoryId" column="category_id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="extension" column="extension" jdbcType="VARCHAR"/>
|
||||
@ -18,9 +19,9 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,category_id,name,
|
||||
extension,size,disk,
|
||||
file_id,path,url,
|
||||
created_at
|
||||
id,type,category_id,
|
||||
name,extension,size,
|
||||
disk,file_id,path,
|
||||
url,created_at
|
||||
</sql>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user