parent
e5c79d8c90
commit
e6f2c3401d
25 changed files with 758 additions and 567 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@ |
||||
package com.teaching.backend.controller.resource; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.service.impl.resource.ResourceMysqlServiceImpl; |
||||
import com.teaching.backend.service.impl.resource.ResourceServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/resourcemysql") |
||||
@Api(tags= "数据库资源管理") |
||||
public class ResourceMysqlController { |
||||
private ResourceMysqlServiceImpl resourceMysqlService; |
||||
|
||||
private ResourceServiceImpl resourceService; |
||||
|
||||
//添加资源
|
||||
@PostMapping("/add") |
||||
@ApiOperation(value = "添加资源") |
||||
public BaseResponse<String> addFile(@RequestPart("file") MultipartFile file, ResourceMysql resourceMysql) { |
||||
System.out.println("资源:"+ resourceMysql); |
||||
System.out.println(file); |
||||
String url = resourceService.upload(file).getData().getUrl(); |
||||
System.out.println(url); |
||||
//return ResultUtils.success("添加xx");
|
||||
return resourceMysqlService.resourceUpload(file, resourceMysql); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@ |
||||
package com.teaching.backend.mapper.resource; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
|
||||
/** |
||||
* <p> |
||||
* Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
public interface ResourceMysqlMapper extends BaseMapper<ResourceMysql> { |
||||
|
||||
} |
@ -0,0 +1,65 @@ |
||||
package com.teaching.backend.model.entity.resource; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import java.io.Serializable; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @author wenyu |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@TableName("resource") |
||||
@ApiModel(value="Resource对象", description="") |
||||
public class ResourceMysql implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
private String id; |
||||
|
||||
@ApiModelProperty(value = "课程id") |
||||
private String courseId; |
||||
|
||||
@ApiModelProperty(value = "章节id") |
||||
private String chapterId; |
||||
|
||||
@ApiModelProperty(value = "知识点id") |
||||
private String knowledgeId; |
||||
|
||||
@ApiModelProperty(value = "资源名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "资源类型") |
||||
private Integer type; |
||||
|
||||
@ApiModelProperty(value = "资源路径") |
||||
private String path; |
||||
|
||||
@ApiModelProperty(value = "资源状态") |
||||
private Integer status; |
||||
|
||||
@ApiModelProperty(value = "标签") |
||||
private String tags; |
||||
|
||||
@ApiModelProperty(value = "简介") |
||||
private String description; |
||||
|
||||
@ApiModelProperty(value = "封面") |
||||
private String img; |
||||
|
||||
|
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.teaching.backend.service.impl.resource; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.mapper.resource.ResourceMysqlMapper; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.service.resource.IResourceMysqlService; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@Service |
||||
public class ResourceMysqlServiceImpl extends ServiceImpl<ResourceMysqlMapper, ResourceMysql> implements IResourceMysqlService { |
||||
private ResourceServiceImpl resourceService; |
||||
@Override |
||||
public BaseResponse<String> resourceUpload(MultipartFile file, ResourceMysql resourceMysql) { |
||||
System.out.println(1); |
||||
System.out.println(file); |
||||
String url = resourceService.upload(file).getData().getUrl(); |
||||
resourceMysql.setPath(url); |
||||
save(resourceMysql); |
||||
return ResultUtils.success("添加成功"); |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.teaching.backend.service.resource; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务类 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
public interface IResourceMysqlService extends IService<ResourceMysql> { |
||||
|
||||
BaseResponse<String> resourceUpload(MultipartFile file, ResourceMysql resourceMysql); |
||||
} |
Loading…
Reference in new issue