mirror of https://github.com/jeecgboot/jeecg-boot
feat: export details secure access
parent
b8124a880f
commit
08528696c7
|
@ -11,7 +11,6 @@ import freemarker.template.TemplateException;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jeecg.common.api.dto.message.TemplateMessageDTO;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
@ -626,11 +625,27 @@ public class InvoiceController {
|
||||||
@RequestParam("type") String type
|
@RequestParam("type") String type
|
||||||
) throws IOException, UserException {
|
) throws IOException, UserException {
|
||||||
log.info("Request for downloading invoice detail by client and period : \nclient : {} \nshops : {}\nstart date : {}\nend date : {}\ntype : {}", clientId, shopIds, startDate, endDate, type);
|
log.info("Request for downloading invoice detail by client and period : \nclient : {} \nshops : {}\nstart date : {}\nend date : {}\ntype : {}", clientId, shopIds, startDate, endDate, type);
|
||||||
List<FactureDetail> invoiceDetails = shippingInvoiceService.getInvoiceDetailByShopsAndPeriod(shopIds, startDate, endDate, type);
|
boolean isEmployee = securityService.checkIsEmployee();
|
||||||
Client client = clientService.getById(clientId);
|
Client client = clientService.getById(clientId);
|
||||||
|
Client currentClient;
|
||||||
|
if(client == null) {
|
||||||
|
log.error("Client {} not found", clientId);
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
if (!isEmployee) {
|
||||||
|
currentClient = clientService.getCurrentClient();
|
||||||
|
if (currentClient == null) {
|
||||||
|
log.error("Client is not registered as a user : {}", clientId);
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
if(!clientId.equals(currentClient.getId())) {
|
||||||
|
log.error("Client {} is not authorized to download invoice detail for client {}", currentClient.getInternalCode(), client.getInternalCode());
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<FactureDetail> invoiceDetails = shippingInvoiceService.getInvoiceDetailByShopsAndPeriod(shopIds, startDate, endDate, type);
|
||||||
String period = startDate + "-" + endDate;
|
String period = startDate + "-" + endDate;
|
||||||
return shippingInvoiceService.exportToExcel(invoiceDetails, Collections.emptyList(), Collections.emptyList(), period, client.getInvoiceEntity(), client.getInternalCode());
|
return shippingInvoiceService.exportToExcel(invoiceDetails, Collections.emptyList(), Collections.emptyList(), period, client.getInvoiceEntity(), client.getInternalCode());
|
||||||
|
|
||||||
}
|
}
|
||||||
@GetMapping(value = "/downloadInvoiceInventory")
|
@GetMapping(value = "/downloadInvoiceInventory")
|
||||||
public byte[] downloadInvoiceInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException {
|
public byte[] downloadInvoiceInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue