Commit a0191e8b by 伍思炜

1

parent c4f8324a
package com.winsun.controller; package com.winsun.controller;
import com.winsun.auth.core.annotion.Permission; import com.winsun.auth.core.annotion.Permission;
import com.winsun.auth.core.base.controller.BaseController;
import com.winsun.auth.core.common.model.ResponseData;
import com.winsun.auth.core.shiro.ShiroUser;
import com.winsun.constant.FilePath; import com.winsun.constant.FilePath;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.Base64;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import sun.misc.BASE64Encoder;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.HashMap;
import java.util.List;
/** /**
* @Author xuede * @Author xuede
...@@ -18,14 +27,24 @@ import java.io.FileInputStream; ...@@ -18,14 +27,24 @@ import java.io.FileInputStream;
*/ */
@Slf4j @Slf4j
@RestController @RestController
public class ImgController { public class ImgController extends BaseController {
/**
* 服务器访问路径
*/
private static String pathPre = "/vdb/springboot/school_center/manager/";
//menuname = "图片路径" 只支持jpeg 和 png //menuname = "图片路径" 只支持jpeg 和 png
@Permission(menuname = "图片查询", value = "/images/**", produces ={MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_PNG_VALUE}) @Permission(menuname = "图片查询", value = "/images", method = RequestMethod.POST,produces ={MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_PNG_VALUE})
public byte[] getbackground(HttpServletRequest request) { public ResponseData<String> getbackground(String url) {
byte[] bytes={}; ShiroUser shiroUser = getShiroUser();
request.getServletPath(); if (!shiroUser.getRoleNames().stream().anyMatch(roleName -> StringUtils.equalsAny(roleName, "超级管理员", "系统管理员","县分管理员(订单)","合伙人"))) {
String imgurl= FilePath.BACKGROUNDIMG.getValue()+"/"+request.getServletPath(); return ResponseData.error("无数据权限");
}
System.out.println(url);
url.replace("manager/ciop","");
byte[] bytes=new byte[10];
String imgurl= pathPre + FilePath.BACKGROUNDIMG.getValue()+"/"+url;
imgurl = imgurl.replace("//", "/"); imgurl = imgurl.replace("//", "/");
File file = new File(imgurl); File file = new File(imgurl);
...@@ -33,8 +52,6 @@ public class ImgController { ...@@ -33,8 +52,6 @@ public class ImgController {
try { try {
inputStream = new FileInputStream(file); inputStream = new FileInputStream(file);
bytes = new byte[0];
bytes = new byte[inputStream.available()]; bytes = new byte[inputStream.available()];
if (inputStream != null) { if (inputStream != null) {
...@@ -51,6 +68,6 @@ public class ImgController { ...@@ -51,6 +68,6 @@ public class ImgController {
}catch (Exception e){} }catch (Exception e){}
} }
} }
return bytes; return ResponseData.success(Base64.encodeBase64String(bytes));
} }
} }
...@@ -253,6 +253,9 @@ public class StudentCardVerifyController extends BaseController { ...@@ -253,6 +253,9 @@ public class StudentCardVerifyController extends BaseController {
@RequestParam(name = "pageNo") int pageNo, @RequestParam(name = "pageNo") int pageNo,
@RequestParam(name = "pageSize") int pageSize) { @RequestParam(name = "pageSize") int pageSize) {
ShiroUser user = getShiroUser(); ShiroUser user = getShiroUser();
if (!user.getRoleNames().stream().anyMatch(roleName -> StringUtils.equalsAny(roleName, "超级管理员", "系统管理员"))) {
return ResponseData.error("无数据权限");
}
Page<StudentCard> page = new Page<>(pageNo, pageSize); Page<StudentCard> page = new Page<>(pageNo, pageSize);
Wrapper<StudentCard> studentCardWrapper = new EntityWrapper<>(); Wrapper<StudentCard> studentCardWrapper = new EntityWrapper<>();
......
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