Commit bff7861b authored by liqin's avatar liqin 💬

bug fixed

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