package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.ProductTabsMapper;
import com.gxwebsoft.oa.service.ProductTabsService;
import com.gxwebsoft.oa.entity.ProductTabs;
import com.gxwebsoft.oa.param.ProductTabsParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品标签记录表Service实现
 *
 * @author 科技小王子
 * @since 2023-12-14 15:55:52
 */
@Service
public class ProductTabsServiceImpl extends ServiceImpl<ProductTabsMapper, ProductTabs> implements ProductTabsService {

    @Override
    public PageResult<ProductTabs> pageRel(ProductTabsParam param) {
        PageParam<ProductTabs, ProductTabsParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<ProductTabs> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<ProductTabs> listRel(ProductTabsParam param) {
        List<ProductTabs> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<ProductTabs, ProductTabsParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public ProductTabs getByIdRel(Integer tabId) {
        ProductTabsParam param = new ProductTabsParam();
        param.setTabId(tabId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
