package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsTrademarkMapper;
import com.gxwebsoft.oa.service.OaAssetsTrademarkService;
import com.gxwebsoft.oa.entity.OaAssetsTrademark;
import com.gxwebsoft.oa.param.OaAssetsTrademarkParam;
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-10-18 19:46:21
 */
@Service
public class OaAssetsTrademarkServiceImpl extends ServiceImpl<OaAssetsTrademarkMapper, OaAssetsTrademark> implements OaAssetsTrademarkService {

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

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

    @Override
    public OaAssetsTrademark getByIdRel(Integer id) {
        OaAssetsTrademarkParam param = new OaAssetsTrademarkParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
