拦截器
This commit is contained in:
parent
12b0f4eab7
commit
e49dc747e7
|
|
@ -247,7 +247,7 @@ public class BssVatInvoiceController {
|
||||||
good.setUnit(commodityUnits.get(i).getWord());
|
good.setUnit(commodityUnits.get(i).getWord());
|
||||||
}
|
}
|
||||||
if (ToolUtil.checkListSize(commodityNums) && !StringUtil.isBlank(commodityNums.get(i).getWord())) {
|
if (ToolUtil.checkListSize(commodityNums) && !StringUtil.isBlank(commodityNums.get(i).getWord())) {
|
||||||
good.setNum(Integer.valueOf(commodityNums.get(i).getWord()));
|
good.setNum(Double.valueOf(commodityNums.get(i).getWord()));
|
||||||
}
|
}
|
||||||
if (ToolUtil.checkListSize(commodityPrices) && commodityPrices.size() > i && !StringUtil.isBlank(commodityPrices.get(i).getWord())) {
|
if (ToolUtil.checkListSize(commodityPrices) && commodityPrices.size() > i && !StringUtil.isBlank(commodityPrices.get(i).getWord())) {
|
||||||
good.setUnitPrice(commodityPrices.get(i).getWord());
|
good.setUnitPrice(commodityPrices.get(i).getWord());
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,13 @@ import com.cwhelp.modules.system.service.ApiBizService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by huangjc on 2019/12/1 0001.
|
* Created by huangjc on 2019/12/1 0001.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api_biz")
|
@RequestMapping("/apiBiz")
|
||||||
public class BssApiBizController {
|
public class BssApiBizController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -63,6 +62,7 @@ public class BssApiBizController {
|
||||||
return ResultVoUtil.success(ApiConst.API_OPT_SUCCESS_MSG, vatInvoice);
|
return ResultVoUtil.success(ApiConst.API_OPT_SUCCESS_MSG, vatInvoice);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
return new ResultVo(ApiConst.API_UPLOAD_PICTURE_FAILED_CODE, ApiConst.API_UPLOAD_PICTURE_FAILED_MSG);
|
return new ResultVo(ApiConst.API_UPLOAD_PICTURE_FAILED_CODE, ApiConst.API_UPLOAD_PICTURE_FAILED_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<body class="timo-layout-page">
|
<body class="timo-layout-page">
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-header timo-card-header">
|
<div class="layui-card-header timo-card-header">
|
||||||
<span><i class="fa fa-bars"></i> 账套信息管理</span>
|
<span><i class="fa fa-bars"></i> 客户公司信息管理</span>
|
||||||
<i class="layui-icon layui-icon-refresh refresh-btn"></i>
|
<i class="layui-icon layui-icon-refresh refresh-btn"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.cwhelp.common.config;
|
||||||
|
|
||||||
|
import com.cwhelp.common.interceptor.ApiLoginInterceptor;
|
||||||
|
import org.springframework.boot.SpringBootConfiguration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by huangjc on 2019/12/19 0019.
|
||||||
|
*/
|
||||||
|
@SpringBootConfiguration
|
||||||
|
public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
|
||||||
|
registry.addInterceptor(new ApiLoginInterceptor()).addPathPatterns("/apiBiz/**")
|
||||||
|
.addPathPatterns("/api/biz/**").excludePathPatterns(Arrays.asList("/css/**", "/js/**", "/images/**", "/lib/**"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,9 +15,9 @@ import java.io.PrintWriter;
|
||||||
/**
|
/**
|
||||||
* Created by huangjc on 2019/12/10 0010.
|
* Created by huangjc on 2019/12/10 0010.
|
||||||
*/
|
*/
|
||||||
@Component
|
//@Component
|
||||||
@ServletComponentScan
|
//@ServletComponentScan
|
||||||
@WebFilter(filterName = "apiLoginFilter", urlPatterns = {"/api_biz/*", "/api/biz/*"})
|
//@WebFilter(filterName = "apiLoginFilter", urlPatterns = {"/api_biz/*", "/api/biz/*"})
|
||||||
public class ApiLoginFilter implements Filter {
|
public class ApiLoginFilter implements Filter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -28,7 +28,7 @@ public class ApiLoginFilter implements Filter {
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
if(session.getAttribute(token) == null){
|
if(session.getAttribute(token) == null){
|
||||||
response.setStatus(401);
|
response.setStatus(401);
|
||||||
response.setContentType("text/html;charset=utf-8");
|
response.setContentType("application/json;charset=utf-8");
|
||||||
PrintWriter writer = response.getWriter();
|
PrintWriter writer = response.getWriter();
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code","401");
|
json.put("code","401");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.cwhelp.common.interceptor;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by huangjc on 2019/12/19 0019.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ApiLoginInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
if(session.getAttribute(token) == null){
|
||||||
|
response.setStatus(401);
|
||||||
|
response.setContentType("application/json;charset=utf-8");
|
||||||
|
PrintWriter writer = response.getWriter();
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("code","401");
|
||||||
|
json.put("msg","请先登录!");
|
||||||
|
writer.print(json);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -48,6 +48,7 @@ public class ShiroConfig {
|
||||||
LinkedHashMap<String, String> filterMap = new LinkedHashMap<>();
|
LinkedHashMap<String, String> filterMap = new LinkedHashMap<>();
|
||||||
filterMap.put("/login", "anon");
|
filterMap.put("/login", "anon");
|
||||||
filterMap.put("/api/me/login", "anon");
|
filterMap.put("/api/me/login", "anon");
|
||||||
|
filterMap.put("/apiBiz/**", "anon");
|
||||||
filterMap.put("/logout", "anon");
|
filterMap.put("/logout", "anon");
|
||||||
filterMap.put("/captcha", "anon");
|
filterMap.put("/captcha", "anon");
|
||||||
filterMap.put("/noAuth", "anon");
|
filterMap.put("/noAuth", "anon");
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class BssGoods implements Serializable {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
// 数量
|
// 数量
|
||||||
private Integer num;
|
private Double num;
|
||||||
// 细节金额
|
// 细节金额
|
||||||
@Column(name = "detail_amount")
|
@Column(name = "detail_amount")
|
||||||
private BigDecimal detailAmount;
|
private BigDecimal detailAmount;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ public class User implements Serializable {
|
||||||
private BssPlatform bssPlatform;
|
private BssPlatform bssPlatform;
|
||||||
|
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "sys_user_role",
|
@JoinTable(name = "sys_user_role",
|
||||||
joinColumns = @JoinColumn(name="user_id"),
|
joinColumns = @JoinColumn(name="user_id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "role_id"))
|
inverseJoinColumns = @JoinColumn(name = "role_id"))
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class ApiBizServiceImpl implements ApiBizService{
|
||||||
good.setUnit(commodityUnits.get(i).getWord());
|
good.setUnit(commodityUnits.get(i).getWord());
|
||||||
}
|
}
|
||||||
if (ToolUtil.checkListSize(commodityNums) && !StringUtil.isBlank(commodityNums.get(i).getWord())) {
|
if (ToolUtil.checkListSize(commodityNums) && !StringUtil.isBlank(commodityNums.get(i).getWord())) {
|
||||||
good.setNum(Integer.valueOf(commodityNums.get(i).getWord()));
|
good.setNum(Double.valueOf(commodityNums.get(i).getWord()));
|
||||||
}
|
}
|
||||||
if (ToolUtil.checkListSize(commodityPrices) && commodityPrices.size() > i && !StringUtil.isBlank(commodityPrices.get(i).getWord())) {
|
if (ToolUtil.checkListSize(commodityPrices) && commodityPrices.size() > i && !StringUtil.isBlank(commodityPrices.get(i).getWord())) {
|
||||||
good.setUnitPrice(commodityPrices.get(i).getWord());
|
good.setUnitPrice(commodityPrices.get(i).getWord());
|
||||||
|
|
@ -128,7 +128,7 @@ public class ApiBizServiceImpl implements ApiBizService{
|
||||||
BssGoods good = new BssGoods();
|
BssGoods good = new BssGoods();
|
||||||
good.setName(InvoiceTypeEnum.TRAIN_INVOICE.getName());
|
good.setName(InvoiceTypeEnum.TRAIN_INVOICE.getName());
|
||||||
good.setDetailAmount(new BigDecimal(wordsResult.getTicketRates()));
|
good.setDetailAmount(new BigDecimal(wordsResult.getTicketRates()));
|
||||||
good.setNum(1);
|
good.setNum(1d);
|
||||||
good.setUnit("张");
|
good.setUnit("张");
|
||||||
good.setUnitPrice(wordsResult.getTicketRates());
|
good.setUnitPrice(wordsResult.getTicketRates());
|
||||||
goods.add(good);
|
goods.add(good);
|
||||||
|
|
|
||||||
7
pom.xml
7
pom.xml
|
|
@ -46,6 +46,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<!-- 打包時 加上 解決jar包衝突 -->
|
||||||
|
<!--<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--spring data jpa持久层框架-->
|
<!--spring data jpa持久层框架-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue