| | |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | |
| | | } |
| | | |
| | | public List<SupplierSub> getSubSupplier() { |
| | | List<SupplierSub> supplierSubs = new ArrayList<>(); |
| | | SupplierDTO supplierDTO = supplierMapper.getCurrentSupplier(SecurityUtils.getUserId()); |
| | | if(ObjectUtils.isEmpty(supplierDTO)){ |
| | | throw new ValidationException("供应商信息不存在"); |
| | | } |
| | | return supplierSubMapper.getSubSupplier(String.valueOf(supplierDTO.getId())); |
| | | |
| | | List<SupplierSub> subSupplier = supplierSubMapper.getSubSupplier(String.valueOf(supplierDTO.getId())); |
| | | if (!CollectionUtils.isEmpty(subSupplier)) { |
| | | subSupplier.forEach(s -> { |
| | | s.setIsSub(true); |
| | | s.setType(0); |
| | | }); |
| | | supplierSubs.addAll(subSupplier); |
| | | } |
| | | return supplierSubs; |
| | | } |
| | | |
| | | public SupplierSub getById(Long id) { |
| | | return supplierSubMapper.selectById(id); |
| | | } |
| | | |
| | | public CurrentUserDTO getSwitchById(Long id) { |
| | | public CurrentUserDTO getSwitchById(Long id, int type) { |
| | | String userId = ""; |
| | | if (type == 1) { |
| | | userId = SecurityUtils.getUserId(); |
| | | }else { |
| | | SupplierSub supplierSub = supplierSubMapper.selectById(id); |
| | | String userId = supplierSub.getUserId(); |
| | | supplierSub.setType(0); |
| | | userId = supplierSub.getUserId(); |
| | | } |
| | | |
| | | CurrentUserDTO result = new CurrentUserDTO(); |
| | | |
| | |
| | | } |
| | | }else if(Constants.USER_TYPE.supplier.name().equals(user.getType())){ |
| | | result.setSupplierDTO(supplierService.getCurrentSupplier()); |
| | | SupplierSub sub = supplierSubMapper.getCurrentSupplier(SecurityUtils.getUserId()); |
| | | SupplierSub sub = supplierSubMapper.getCurrentSupplier(userId); |
| | | if (!ObjectUtils.isEmpty(sub)) { |
| | | sub.setType(0); |
| | | result.setIsSubSupplier(true); |
| | | result.setSupplierSub(sub); |
| | | result.setSwitchFlag(true); |
| | |
| | | public User getUserById(String id){ |
| | | return userMapper.selectById(id); |
| | | } |
| | | |
| | | public List<SupplierSub> getAllSupplier() { |
| | | List<SupplierSub> supplierSubs = new ArrayList<>(); |
| | | SupplierDTO supplierDTO = supplierMapper.getCurrentSupplier(SecurityUtils.getUserId()); |
| | | if (!ObjectUtils.isEmpty(supplierDTO)) { |
| | | SupplierSub subParent = new SupplierSub(); |
| | | subParent.setId((long) -1); |
| | | subParent.setUserId(supplierDTO.getUserId()); |
| | | subParent.setSupplierId(supplierDTO.getId()); |
| | | subParent.setName(supplierDTO.getName()); |
| | | subParent.setContact(supplierDTO.getContactName()); |
| | | subParent.setPhone(supplierDTO.getContactTel()); |
| | | subParent.setIsEnabled(supplierDTO.getIsEnabled()); |
| | | subParent.setIsSub(false); |
| | | subParent.setType(1); |
| | | supplierSubs.add(subParent); |
| | | } |
| | | List<SupplierSub> subSupplier = supplierSubMapper.getSubSupplier(String.valueOf(supplierDTO.getId())); |
| | | if (!CollectionUtils.isEmpty(subSupplier)) { |
| | | subSupplier.forEach(s->{ |
| | | s.setIsSub(true); |
| | | s.setType(0); |
| | | }); |
| | | supplierSubs.addAll(subSupplier); |
| | | } |
| | | return supplierSubs; |
| | | } |
| | | } |