package com.zteits.park.dao.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.zteits.clouds.api.apibase.constants.DataStatusEnum; import com.zteits.clouds.api.dto.park.param.QueryXcCarChargeAuditPageRequest; import com.zteits.park.dao.XcCarChargeAuditDao; import com.zteits.park.domain.XcCarChargeAudit; import com.zteits.park.domain.XcCarChargeAuditExample; import com.zteits.park.mapper.XcCarChargeAuditMapper; import com.zteits.park.mapper.smapper.XcCarChargeAuditSMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; import java.util.List; /** * 车辆收费审核Dao实现类 */ @Component public class XcCarChargeAuditDaoImpl implements XcCarChargeAuditDao { @Autowired private XcCarChargeAuditMapper xcCarChargeAuditMapper; @Autowired private XcCarChargeAuditSMapper xcCarChargeAuditSMapper; @Override public int updateByPrimaryKeySelective(XcCarChargeAudit record) { return xcCarChargeAuditMapper.updateByPrimaryKeySelective(record); } @Override public List selectByExample(XcCarChargeAuditExample example) { return xcCarChargeAuditMapper.selectByExample(example); } @Override public XcCarChargeAudit selectByPrimaryKey(Long id) { return xcCarChargeAuditMapper.selectByPrimaryKey(id); } @Override public long countByExample(XcCarChargeAuditExample example) { return xcCarChargeAuditMapper.countByExample(example); } @Override public int updateByExampleSelective(XcCarChargeAudit record, XcCarChargeAuditExample example) { return xcCarChargeAuditMapper.updateByExampleSelective(record, example); } @Override public int saveXcCarChargeAudit(XcCarChargeAudit xcCarChargeAudit) { if (xcCarChargeAudit.getCreateTime() == null) { xcCarChargeAudit.setCreateTime(new Date()); } xcCarChargeAudit.setDataState(DataStatusEnum.DATA_STATUS_VALID.value()); return xcCarChargeAuditMapper.insertSelective(xcCarChargeAudit); } @Override public int updateAuditStatusBatch(List ids, Byte auditStatus, String auditor) { XcCarChargeAudit updateAudit = new XcCarChargeAudit(); updateAudit.setAuditStatus(auditStatus); updateAudit.setAuditTime(new Date()); updateAudit.setAuditor(auditor); XcCarChargeAuditExample updateExample = new XcCarChargeAuditExample(); updateExample.createCriteria().andIdIn(ids).andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); return xcCarChargeAuditMapper.updateByExampleSelective(updateAudit, updateExample); } @Override public int deleteByPrimaryKey(Long id, String opId, String opName) { XcCarChargeAudit updateAudit = new XcCarChargeAudit(); updateAudit.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value()); // 设置为无效状态,实现逻辑删除 XcCarChargeAuditExample updateExample = new XcCarChargeAuditExample(); updateExample.createCriteria().andIdEqualTo(id).andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); return xcCarChargeAuditMapper.updateByExampleSelective(updateAudit, updateExample); } @Override public PageInfo queryXcCarChargeAuditForPage(QueryXcCarChargeAuditPageRequest request) { PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize()); List xcCarChargeAudits = xcCarChargeAuditSMapper.queryXcCarChargeAuditForPage(request); return new PageInfo<>(xcCarChargeAudits); } @Override public XcCarChargeAudit queryLastXcCarChargeAuditByCarNumber(String carNumber) { QueryXcCarChargeAuditPageRequest request = new QueryXcCarChargeAuditPageRequest(); request.setCarNumber(carNumber); List audits = xcCarChargeAuditSMapper.queryXcCarChargeAuditForPage(request); return audits.isEmpty() ? null : audits.get(0); } }