|
|
|
@ -1,12 +1,19 @@
|
|
|
|
|
package com.dsideal.resource.Res.Controller;
|
|
|
|
|
|
|
|
|
|
import com.dsideal.resource.Base.Model.BaseModel;
|
|
|
|
|
import com.dsideal.resource.Interceptor.EmptyInterface;
|
|
|
|
|
import com.dsideal.resource.Interceptor.IsNumericInterface;
|
|
|
|
|
import com.dsideal.resource.Interceptor.JwtCheckInterface;
|
|
|
|
|
import com.dsideal.resource.Res.Model.ResourceModel;
|
|
|
|
|
import com.dsideal.resource.Util.CommonUtil;
|
|
|
|
|
import com.dsideal.resource.Util.JwtUtil;
|
|
|
|
|
import com.dsideal.resource.Util.MinioUtils;
|
|
|
|
|
import com.dsideal.resource.Util.RetKit;
|
|
|
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
import com.jfinal.core.Controller;
|
|
|
|
|
import com.jfinal.ext.interceptor.GET;
|
|
|
|
|
import com.jfinal.ext.interceptor.POST;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import io.github.yedaxia.apidocs.ApiDoc;
|
|
|
|
|
import io.minio.errors.*;
|
|
|
|
|
|
|
|
|
@ -19,6 +26,9 @@ import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
@ApiDoc
|
|
|
|
|
public class ResourceController extends Controller {
|
|
|
|
|
|
|
|
|
|
ResourceModel rm = new ResourceModel();
|
|
|
|
|
BaseModel bm = new BaseModel();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取Minio的上传签名
|
|
|
|
|
*
|
|
|
|
@ -43,43 +53,98 @@ public class ResourceController extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增资源
|
|
|
|
|
* 增加
|
|
|
|
|
*
|
|
|
|
|
* @param resource_title 资源名称
|
|
|
|
|
* @param resource_size_int 资源大小
|
|
|
|
|
* @param extension 扩展名
|
|
|
|
|
* @param file_id 对应文件的id号,是一个guid
|
|
|
|
|
* @param file_md5 文件的md5值
|
|
|
|
|
* @param thumb_id 缩略图id
|
|
|
|
|
* @param scheme_id 结构id
|
|
|
|
|
* @param structure_id 结构id
|
|
|
|
|
* @param down_count 下载次数
|
|
|
|
|
* @param stage_id 学段id
|
|
|
|
|
* @param subject_id 科目id
|
|
|
|
|
*/
|
|
|
|
|
public void addResource() {
|
|
|
|
|
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@JwtCheckInterface({})
|
|
|
|
|
public void addResourceBase(String resource_title, long resource_size_int,
|
|
|
|
|
String extension, String file_id, String file_md5,
|
|
|
|
|
String thumb_id, int scheme_id, int structure_id,
|
|
|
|
|
int down_count, int stage_id, int subject_id) {
|
|
|
|
|
//当前登录人员
|
|
|
|
|
String person_id = JwtUtil.getPersonId(getRequest());
|
|
|
|
|
String resource_size = CommonUtil.formatFileSize(resource_size_int);
|
|
|
|
|
String person_name = bm.getPersonById(person_id).getStr("person_name");
|
|
|
|
|
rm.addResourceBase(resource_title, resource_size, resource_size_int, person_name, person_id, extension,
|
|
|
|
|
file_id, file_md5, thumb_id, scheme_id, structure_id, down_count, stage_id, subject_id);
|
|
|
|
|
renderJson(RetKit.renderSuccess("操作成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除资源
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
|
|
|
|
* @param resource_id_int 资源id
|
|
|
|
|
* @param resource_id_int 主键
|
|
|
|
|
*/
|
|
|
|
|
public void deleteResource(int resource_id_int) {
|
|
|
|
|
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@JwtCheckInterface({})
|
|
|
|
|
@IsNumericInterface({"resource_id_int"})
|
|
|
|
|
public void delResourceBaseById(int resource_id_int) {
|
|
|
|
|
rm.delResourceBaseById(resource_id_int);
|
|
|
|
|
renderJson(RetKit.renderSuccess("操作成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改资源
|
|
|
|
|
* 按ID修改
|
|
|
|
|
*
|
|
|
|
|
* @param resource_id_int 资源id
|
|
|
|
|
* @param resource_id_int 主键
|
|
|
|
|
* @param resource_title 资源名称
|
|
|
|
|
* @param resource_size 资源大小
|
|
|
|
|
* @param resource_size_int 资源大小
|
|
|
|
|
* @param person_name 上传人姓名
|
|
|
|
|
* @param person_id 上传人员id
|
|
|
|
|
* @param extension 扩展名
|
|
|
|
|
* @param file_id 对应文件的id号,是一个guid
|
|
|
|
|
* @param file_md5 文件的md5值
|
|
|
|
|
* @param thumb_id 缩略图id
|
|
|
|
|
* @param scheme_id 结构id
|
|
|
|
|
* @param structure_id 结构id
|
|
|
|
|
* @param down_count 下载次数
|
|
|
|
|
* @param stage_id 学段id
|
|
|
|
|
* @param subject_id 科目id
|
|
|
|
|
* @param update_ts 更新时间
|
|
|
|
|
*/
|
|
|
|
|
public void updateResource(int resource_id_int) {
|
|
|
|
|
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@JwtCheckInterface({})
|
|
|
|
|
@IsNumericInterface({"resource_id_int"})
|
|
|
|
|
public void updateResourceBaseById(int resource_id_int, String resource_title, String resource_size, long resource_size_int, String person_name, int person_id, String extension, String file_id, String file_md5, String thumb_id, int scheme_id, int structure_id, int down_count, int stage_id, int subject_id, java.util.Date update_ts) {
|
|
|
|
|
rm.updateResourceBaseById(resource_id_int, resource_title, resource_size, resource_size_int, person_name, person_id, extension, file_id, file_md5, thumb_id, scheme_id, structure_id, down_count, stage_id, subject_id, update_ts);
|
|
|
|
|
renderJson(RetKit.renderSuccess("操作成功"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询资源
|
|
|
|
|
* 按ID查询
|
|
|
|
|
*
|
|
|
|
|
* @param resource_id_int 资源id
|
|
|
|
|
* @param resource_id_int 主键
|
|
|
|
|
*/
|
|
|
|
|
public void queryResource(int resource_id_int) {
|
|
|
|
|
|
|
|
|
|
@Before({GET.class})
|
|
|
|
|
@JwtCheckInterface({})
|
|
|
|
|
@IsNumericInterface("{resource_id_int}")
|
|
|
|
|
public void getResourceBaseById(int resource_id_int) {
|
|
|
|
|
renderJson(RetKit.renderSuccess(rm.getResourceBaseById(resource_id_int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有资源
|
|
|
|
|
* 分页查询
|
|
|
|
|
*
|
|
|
|
|
* @param pageNum 页码
|
|
|
|
|
* @param pageSize 每页数量
|
|
|
|
|
*/
|
|
|
|
|
public void queryAllResource() {
|
|
|
|
|
|
|
|
|
|
@Before({GET.class})
|
|
|
|
|
@JwtCheckInterface({})
|
|
|
|
|
public void getResourceBaseList(int pageNum, int pageSize) {
|
|
|
|
|
Page<Record> listPage = rm.getResourceBaseList(pageNum, pageSize);
|
|
|
|
|
renderJson(RetKit.renderSuccess(listPage));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|