package com.gxwebsoft.love.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.love.mapper.UserPlanIconMapper;
import com.gxwebsoft.love.service.UserPlanIconService;
import com.gxwebsoft.love.entity.UserPlanIcon;
import com.gxwebsoft.love.param.UserPlanIconParam;
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-06-25 18:09:34
 */
@Service
public class UserPlanIconServiceImpl extends ServiceImpl<UserPlanIconMapper, UserPlanIcon> implements UserPlanIconService {

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

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

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

}
