package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.UserFollowMapper;
import com.gxwebsoft.shop.service.UserFollowService;
import com.gxwebsoft.shop.entity.UserFollow;
import com.gxwebsoft.shop.param.UserFollowParam;
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 2022-11-25 19:04:43
 */
@Service
public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFollow> implements UserFollowService {

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

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

    @Override
    public UserFollow getByIdRel(Integer logId) {
        UserFollowParam param = new UserFollowParam();
        param.setLogId(logId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
