package com.gic.haoban.manage.service.service.impl;

import com.gic.api.base.commons.Page;
import com.gic.commons.util.PageHelperUtils;
import com.gic.haoban.manage.api.dto.licence.AppOrderPageDTO;
import com.gic.haoban.manage.api.dto.licence.RenewalUserDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.AppOrderPageQDTO;
import com.gic.haoban.manage.service.entity.TabHaobanAppOrder;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanAppOrderMapper;
import com.gic.haoban.manage.service.entity.TabHaobanRenewalUser;
import com.gic.haoban.manage.service.service.TabHaobanAppOrderService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TabHaobanAppOrder)表服务实现类
 *
 * @author makejava
 * @since 2023-06-21 17:24:20
 */
@Service("tabHaobanAppOrderService")
public class TabHaobanAppOrderServiceImpl implements TabHaobanAppOrderService {
    @Resource
    private TabHaobanAppOrderMapper tabHaobanAppOrderMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TabHaobanAppOrder queryById(Long id) {
        return this.tabHaobanAppOrderMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param tabHaobanAppOrder 实例对象
     * @return 实例对象
     */
    @Override
    public TabHaobanAppOrder insert(TabHaobanAppOrder tabHaobanAppOrder) {
        this.tabHaobanAppOrderMapper.insert(tabHaobanAppOrder);
        return tabHaobanAppOrder;
    }

    @Override
    public void insertBatch(List<TabHaobanAppOrder> entities) {
        this.tabHaobanAppOrderMapper.insertBatch(entities);
    }

    /**
     * 修改数据
     *
     * @param tabHaobanAppOrder 实例对象
     * @return 实例对象
     */
    @Override
    public TabHaobanAppOrder update(TabHaobanAppOrder tabHaobanAppOrder) {
        this.tabHaobanAppOrderMapper.update(tabHaobanAppOrder);
        return this.queryById(tabHaobanAppOrder.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.tabHaobanAppOrderMapper.deleteById(id) > 0;
    }

    @Override
    public Page<AppOrderPageDTO> getAppOrderPage(AppOrderPageQDTO qdto) {
        if (qdto == null){
            return  null;
        }
        PageHelper.startPage(qdto);
        List<TabHaobanAppOrder> page = tabHaobanAppOrderMapper.getAppOrderPage(qdto);
        return PageHelperUtils.changePageHelperToCurrentPage(page, AppOrderPageDTO.class);
    }

    @Override
    public TabHaobanAppOrder queryByOrderId(String orderId) {
        return tabHaobanAppOrderMapper.queryByOrderId(orderId);
    }
}
