Commit bff7861b authored by liqin's avatar liqin 💬

bug fixed

parent 7c43a45c
......@@ -99,12 +99,12 @@ public class MyShiroRealm extends AuthorizingRealm {
if (user == null) {
throw new AuthenticationException("User does not exist!");
}
user = userService.selectByUsername(user.getUserName());
if (JwtTokenUtil.verify(credentials, username) == null) {
throw new AuthenticationException("token invalid");
}
return new SimpleAuthenticationInfo(new TUser(user.getId(), credentials), credentials, getName());
return new SimpleAuthenticationInfo(new TUser(user.getId(), user.getUserName(), user.getOrgId(), user.getOrgName(), credentials), credentials, getName());
}
/**
......
......@@ -9,6 +9,7 @@ import com.github.tobato.fastdfs.domain.fdfs.MetaData;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.domain.fdfs.ThumbImageConfig;
import com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray;
import com.github.tobato.fastdfs.domain.proto.storage.DownloadFileStream;
import com.github.tobato.fastdfs.exception.FdfsServerException;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import lombok.extern.slf4j.Slf4j;
......@@ -21,10 +22,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
......@@ -115,6 +113,17 @@ public class FastDFSUtils {
return storageClient.downloadFile(groupName, path, new DownloadByteArray());
}
/**
* 下载文件(字节数组)
* @return
*/
public static BufferedInputStream downloadFile(String fileUrl, OutputStream outputStream) {
fileUrl = fileUrl.replace(dfsFileAccessBasePath + "/", "");
String groupName = fileUrl.substring(0, fileUrl.indexOf("/"));
String path = fileUrl.substring(fileUrl.indexOf("/") + 1);
return storageClient.downloadFile(groupName, path, new DownloadFileStream(outputStream));
}
/**
* 下载文件
*
......
package cn.wisenergy.chnmuseum.party.common.mybatis;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.model.TUser;
import cn.wisenergy.chnmuseum.party.service.TUserService;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
......@@ -20,9 +17,6 @@ import java.time.LocalDateTime;
@Component
public class MetaObjectHandlerConfig implements MetaObjectHandler {
@Resource
private TUserService userService;
@Override
public void insertFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now();
......@@ -36,11 +30,9 @@ public class MetaObjectHandlerConfig implements MetaObjectHandler {
}
final TUser currentUser = getCurrentUser();
if (currentUser != null) {
final String userName = JwtTokenUtil.getUsername(currentUser.getJwtToken());
final TUser user = this.userService.selectByUsername(userName);
this.setFieldValByName("userId", user.getId(), metaObject);
this.setFieldValByName("userName", user.getUserName(), metaObject);
this.setFieldValByName("orgName", user.getOrgName(), metaObject);
this.setFieldValByName("userId", currentUser.getId(), metaObject);
this.setFieldValByName("userName", currentUser.getUserName(), metaObject);
this.setFieldValByName("orgName", currentUser.getOrgName(), metaObject);
}
}
......
......@@ -15,7 +15,7 @@ public class VideoTestUtil {
private static final String cipher = "3348c95c60520be7";
private static final int dataLength = 4096;
public static void main(String[] args){
public static void main(String[] args) {
//加密视频
new Thread(() -> {
try {
......
......@@ -35,8 +35,11 @@ public class TUser implements Serializable {
private static final long serialVersionUID = 1L;
public TUser(String id, String jwtToken) {
public TUser(String id, String userName, String orgId, String orgName, String jwtToken) {
this.id = id;
this.userName = userName;
this.orgId = orgId;
this.orgName = orgName;
this.jwtToken = jwtToken;
}
......
......@@ -16,6 +16,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
......@@ -44,7 +45,7 @@ public class AssetController extends BaseController {
})
@PostMapping("/getPageList")
@RequiresPermissions("asset:page")
@ApiOperation(value = "获取文件资产分页列表", notes = "获取文件资产分页列表")
@ApiOperation(value = "获取视频汇出分页列表", notes = "获取视频汇出分页列表")
public Map<String, Object> getAssetPageList(GenericPageParam genericPageParam,
@RequestParam(value = "videoContentCatId", required = false) String videoContentCatId,
@RequestParam(value = "videoContentCopyrightOwnerId", required = false) String videoContentCopyrightOwnerId) {
......@@ -59,7 +60,7 @@ public class AssetController extends BaseController {
return getResult(page);
}
@ApiOperation(value = "获取文件资产详情", notes = "获取文件资产详情")
@ApiOperation(value = "获取视频文件详情", notes = "获取视频文件详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
})
......@@ -70,5 +71,18 @@ public class AssetController extends BaseController {
return getResult(asset);
}
@ApiOperation(value = "视频文件汇出", notes = "视频文件汇出")
@ApiImplicitParams({
@ApiImplicitParam(name = "idList", value = "视频文件标识ID集合", dataType = "String", paramType = "path")
})
@PostMapping("/download")
@RequiresPermissions("asset:download")
public void download(@RequestParam("idList") List<String> idList) {
final List<Asset> assetList = assetService.listByIds(idList);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment