package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.IndustryMapper;
import com.gxwebsoft.common.system.service.IndustryService;
import com.gxwebsoft.common.system.entity.Industry;
import com.gxwebsoft.common.system.param.IndustryParam;
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-05-17 11:26:43
 */
@Service
public class IndustryServiceImpl extends ServiceImpl<IndustryMapper, Industry> implements IndustryService {

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

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

    @Override
    public Industry getByIdRel(Integer industryId) {
        IndustryParam param = new IndustryParam();
        param.setIndustryId(industryId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
