package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.TaskRecordMapper;
import com.gxwebsoft.oa.service.TaskRecordService;
import com.gxwebsoft.oa.entity.TaskRecord;
import com.gxwebsoft.oa.param.TaskRecordParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.oa.service.TaskService;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工单回复记录表Service实现
 *
 * @author 科技小王子
 * @since 2023-03-05 00:52:21
 */
@Service
public class TaskRecordServiceImpl extends ServiceImpl<TaskRecordMapper, TaskRecord> implements TaskRecordService {
    @Override
    public PageResult<TaskRecord> pageRel(TaskRecordParam param) {
        PageParam<TaskRecord, TaskRecordParam> page = new PageParam<>(param);
        page.setDefaultOrder("create_time asc");
        List<TaskRecord> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

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

    @Override
    public TaskRecord getByIdRel(Integer taskRecordId) {
        TaskRecordParam param = new TaskRecordParam();
        param.setTaskRecordId(taskRecordId);
      return param.getOne(baseMapper.selectListRel(param));
    }

}
