Blame view

parking-module-park/src/main/java/com/zteits/park/dao/impl/ParkBerthAppointmentConfigDaoImpl.java 4.34 KB
604bda05   王彪总   1
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  package com.zteits.park.dao.impl;
  import com.github.pagehelper.PageHelper;
  import com.github.pagehelper.PageInfo;
  import com.zteits.park.domain.ParkBerthAppointmentConfig;
  import com.zteits.park.domain.ParkBerthAppointmentConfigExample;
  import com.zteits.clouds.api.dto.park.param.ParkBerthAppointmentConfigRequest;
  import com.zteits.park.dao.ParkBerthAppointmentConfigDao;
  import com.zteits.park.domain.ParkBerthAppointmentParkRelExample;
  import com.zteits.park.mapper.ParkBerthAppointmentConfigMapper;
  
  import com.zteits.park.mapper.ParkBerthAppointmentParkRelMapper;
  import org.apache.commons.collections.CollectionUtils;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  import org.springframework.util.StringUtils;
  
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  
  @Component
  public class ParkBerthAppointmentConfigDaoImpl implements  ParkBerthAppointmentConfigDao {
      @Autowired
      private ParkBerthAppointmentConfigMapper parkBerthAppointmentConfigMapper;
  
      @Autowired
      private ParkBerthAppointmentParkRelMapper parkBerthAppointmentParkRelMapper;
  
  
      @Override
      public int saveParkBerthAppointmentConfig(ParkBerthAppointmentConfig parkBerthAppointmentConfig) {
          if(parkBerthAppointmentConfig.getCreateTime()==null){
              parkBerthAppointmentConfig.setCreateTime(new Date());
          }
          return parkBerthAppointmentConfigMapper.insertSelective(parkBerthAppointmentConfig);
      }
  
      @Override
      public int updateByExampleSelective(ParkBerthAppointmentConfig record, ParkBerthAppointmentConfigExample example) {
          return parkBerthAppointmentConfigMapper.updateByExampleSelective(record,example);
      }
  
      @Override
      public int updateByPrimaryKeySelective(ParkBerthAppointmentConfig record) {
          return parkBerthAppointmentConfigMapper.updateByPrimaryKeySelective(record);
      }
  
      @Override
      public List<ParkBerthAppointmentConfig> selectByExample(ParkBerthAppointmentConfigExample example) {
          return parkBerthAppointmentConfigMapper.selectByExample(example);
      }
  
      @Override
      public ParkBerthAppointmentConfig queryByPrimaryKey(Long id) {
          return parkBerthAppointmentConfigMapper.selectByPrimaryKey(id);
      }
  
      @Override
      public List<ParkBerthAppointmentConfig> queryParkBerthAppointmentConfig(ParkBerthAppointmentConfigRequest request) {
          //TODO 编写smapper实现
          ParkBerthAppointmentConfigExample example = new ParkBerthAppointmentConfigExample();
          example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                  .andRuleStateEqualTo(1)
                  .andOrgIdEqualTo(request.getOrgId());
          return parkBerthAppointmentConfigMapper.selectByExample(example);
      }
  
      @Override
      public int batchDeleteParkBerthAppointmentConfigByPrimaryKey(List<Long> ids) {
          int deleteCount = 0;
          //删除主表
          ParkBerthAppointmentConfigExample example = new ParkBerthAppointmentConfigExample();
          example.createCriteria().andIdIn(ids);
          deleteCount += parkBerthAppointmentConfigMapper.deleteByExample(example);
          //删除关系表
          ParkBerthAppointmentParkRelExample exampleTwo = new ParkBerthAppointmentParkRelExample();
          exampleTwo.createCriteria().andAppointmentConfigIdIn(ids);
          deleteCount +=  parkBerthAppointmentParkRelMapper.deleteByExample(exampleTwo);
          return  deleteCount;
      }
  
      @Override
      public PageInfo<ParkBerthAppointmentConfig> queryParkBerthAppointmentConfigForPage(ParkBerthAppointmentConfigRequest request) {
          PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
          //TODO 编写smapper实现
          ParkBerthAppointmentConfigExample example = new ParkBerthAppointmentConfigExample();
          example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                  .andOrgIdEqualTo(request.getOrgId());
  
          List<ParkBerthAppointmentConfig> list = parkBerthAppointmentConfigMapper.selectByExample(example);
  
          if (CollectionUtils.isNotEmpty(list)) {
              return new PageInfo<ParkBerthAppointmentConfig>(list);
          }
          return new PageInfo<ParkBerthAppointmentConfig>(new ArrayList<ParkBerthAppointmentConfig>());
      }
  }