package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaProductTabsMapper;
import com.gxwebsoft.oa.service.OaProductTabsService;
import com.gxwebsoft.oa.entity.OaProductTabs;
import com.gxwebsoft.oa.param.OaProductTabsParam;
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 2024-09-10 20:57:42
 */
@Service
public class OaProductTabsServiceImpl extends ServiceImpl<OaProductTabsMapper, OaProductTabs> implements OaProductTabsService {

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

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

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

}
