Blame view

parking-module-pay/src/main/java/com/zteits/pay/biz/AppOrgServiceImpl.java 2.79 KB
55f68655   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  package com.zteits.pay.biz;/**
   * Created by wb on 2018/11/20.
   */
  
  import com.clouds.common.cache.pay.AppOrgCacheUtil;
  import com.zteits.clouds.api.apibase.bean.BaseRequest;
  import com.zteits.clouds.api.apibase.bean.BizResult;
  import com.zteits.clouds.api.dto.pay.AcctPayoutDTO;
  import com.zteits.clouds.api.dto.pay.AppOrgDTO;
  import com.zteits.clouds.api.dto.pay.param.AppOrgRequest;
  import com.zteits.clouds.api.service.pay.AppOrgService;
  import com.zteits.pay.dao.AppOrgDao;
  import com.zteits.pay.domain.AppOrg;
  import com.zteits.pay.domain.TdCAcctPayout;
  import org.springframework.beans.BeanUtils;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  import org.springframework.util.CollectionUtils;
  
  import java.util.ArrayList;
  import java.util.Comparator;
  import java.util.List;
  import java.util.stream.Collectors;
  
  /**
   * Copyright: Copyright (c) 2018  ZTE-ITS
   *
   * @ClassName: AppOrgServiceImpl
   * @Description:
   * @version: v1.0.0
   * @author: wangbiao
   * @date: 2018/11/20 10:05
   * Modification History:
   * Date         Author          Version         Description
   * ---------------------------------------------------------*
   * 2018/11/20    wangbiao         v1.0.0          创建
   */
  @Service
  public class AppOrgServiceImpl implements AppOrgService {
      @Autowired
      private AppOrgDao appOrgDao;
      @Override
      public BizResult<List<AppOrgDTO>> selectAllAppOrg(BaseRequest request) {
          //先查询缓存
          List<AppOrgDTO> appOrgDTOs = AppOrgCacheUtil.getAppOrgInfoByOrgIds();
          if(CollectionUtils.isEmpty(appOrgDTOs)){
              appOrgDTOs = new ArrayList<>();
              List<AppOrg> appOrgs = appOrgDao.selectAllAppOrg();
              if(!CollectionUtils.isEmpty(appOrgs)){
                  for(AppOrg appOrg : appOrgs) {
                      AppOrgDTO appOrgDTO = new AppOrgDTO();
                      BeanUtils.copyProperties(appOrg, appOrgDTO);
                      appOrgDTOs.add(appOrgDTO);
                      AppOrgCacheUtil.setAppOrgInfoByOrgId(appOrgDTO);
                  }
              }
          }
          appOrgDTOs.sort(Comparator.comparing(appOrg -> appOrg.getOrgId()));
          return new BizResult<List<AppOrgDTO>> (appOrgDTOs);
      }
  
      @Override
      public BizResult<AppOrgDTO> queryAppOrgByOrgId(AppOrgRequest appOrgRequest) {
          //查询缓存
          AppOrgDTO appOrgDTO = AppOrgCacheUtil.getAppOrgInfoByOrgId(appOrgRequest.getOrgId());
          if(appOrgDTO == null) {
              AppOrg appOrg = appOrgDao.queryAppOrgByOrgId(appOrgRequest.getOrgId());
              if (appOrg != null){
                  appOrgDTO = new AppOrgDTO();
                  BeanUtils.copyProperties(appOrg, appOrgDTO);
                  AppOrgCacheUtil.setAppOrgInfoByOrgId(appOrgDTO);
              }
          }
          return new BizResult<>(appOrgDTO);
      }
  }