package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.UserLookMapper;
import com.gxwebsoft.shop.service.UserLookService;
import com.gxwebsoft.shop.entity.UserLook;
import com.gxwebsoft.shop.param.UserLookParam;
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-07-13 23:10:38
 */
@Service
public class UserLookServiceImpl extends ServiceImpl<UserLookMapper, UserLook> implements UserLookService {

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

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

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

}
