Browse Source

平台化

wangqifan 3 years ago
parent
commit
a3ab2c0625

+ 2 - 0
src/main/java/com/izouma/zhumj/domain/sale/Customer.java

@@ -181,6 +181,8 @@ public class Customer extends BaseEntity implements Serializable {
     @Column(nullable = false)
     @Column(nullable = false)
     private Boolean enabled = true;
     private Boolean enabled = true;
 
 
+    private Long companyId;
+
     public void synchronizeContractInfo(Contract contract) {
     public void synchronizeContractInfo(Contract contract) {
         //将合同信息更新到客户管理信息
         //将合同信息更新到客户管理信息
         if (StringUtils.isEmpty(this.contractNumbers)) {
         if (StringUtils.isEmpty(this.contractNumbers)) {

+ 7 - 0
src/main/java/com/izouma/zhumj/service/sale/CustomerService.java

@@ -61,6 +61,10 @@ public class CustomerService {
     public Page<Customer> all(String search, PageQuery pageQuery, Integer customerType, List<Long> saleId, Integer pageType, CustomerSource customerSource, CustomerIndustry industry) {
     public Page<Customer> all(String search, PageQuery pageQuery, Integer customerType, List<Long> saleId, Integer pageType, CustomerSource customerSource, CustomerIndustry industry) {
         return customerRepo.findAll((Specification<Customer>) (root, criteriaQuery, criteriaBuilder) -> {
         return customerRepo.findAll((Specification<Customer>) (root, criteriaQuery, criteriaBuilder) -> {
             List<javax.persistence.criteria.Predicate> predicates = toPredicates(pageQuery, Customer.class, root, criteriaQuery, criteriaBuilder);
             List<javax.persistence.criteria.Predicate> predicates = toPredicates(pageQuery, Customer.class, root, criteriaQuery, criteriaBuilder);
+            if (SecurityUtils.getAuthenticatedUser().getCompanyId() != null) {
+                predicates.add(criteriaBuilder
+                        .equal(root.get("companyId"), SecurityUtils.getAuthenticatedUser().getCompanyId()));
+            }
             if (customerType != null) {
             if (customerType != null) {
                 List<Contract> expireContract = contractRepo.queryExpired(LocalDateTime.now(), LocalDateTime.now()
                 List<Contract> expireContract = contractRepo.queryExpired(LocalDateTime.now(), LocalDateTime.now()
                         .plusDays(customerType));
                         .plusDays(customerType));
@@ -102,6 +106,9 @@ public class CustomerService {
     }
     }
 
 
     public Customer save(Customer customer) {
     public Customer save(Customer customer) {
+        if (SecurityUtils.getAuthenticatedUser().getCompanyId() != null) {
+            customer.setCompanyId(SecurityUtils.getAuthenticatedUser().getCompanyId());
+        }
         if (StringUtils.isEmpty(customer.getCustomerNumber())) {
         if (StringUtils.isEmpty(customer.getCustomerNumber())) {
             customer.setCustomerNumber(customerRepo.nextCustomerNumber());
             customer.setCustomerNumber(customerRepo.nextCustomerNumber());
         }
         }