package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.UserFeedbackMapper;
import com.gxwebsoft.shop.service.UserFeedbackService;
import com.gxwebsoft.shop.entity.UserFeedback;
import com.gxwebsoft.shop.param.UserFeedbackParam;
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-16 22:24:55
 */
@Service
public class UserFeedbackServiceImpl extends ServiceImpl<UserFeedbackMapper, UserFeedback> implements UserFeedbackService {

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

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

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

}
