package com.chinaweal.aiccs.aiccs.revoke.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaweal.aiccs.aiccs.revoke.entity.Tsrevtasklist;
import com.chinaweal.aiccs.aiccs.revoke.service.TsrevtasklistService;
import com.chinaweal.aiccs.common.base.controller.BaseController;
import com.chinaweal.aicorg.model.AICUser;
import com.chinaweal.youfool.framework.springboot.mybatis.plus.page.PageRequestDto;
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 吊销待办 前端控制器
 * </p>
 *
 * @author Lee
 * @since 2021-03-26
 */
@RestController
@RequestMapping("/tsrevtasklist")
public class TsrevtasklistController extends BaseController {

    @Autowired
    private TsrevtasklistService tsrevtasklistService;

    /**
     * 吊销待办分页
     * @param pageRequestDto 分页参数
     * @param request 分页请求
     * @return 分页结果
     */
    @PostMapping("todoList_page")
    public RestResult<?> getTaskListPage(@RequestBody PageRequestDto pageRequestDto, HttpServletRequest request){
        pageRequestDto.checkDefault(null, null, "SENDERTIME");
        AICUser curUser = getLoginUser(request);

        // 封装分页参数
        Tsrevtasklist taskListParam = new Tsrevtasklist();
        taskListParam.setSignuserid(curUser.getPrimaryKey());

        Map<String, Object> customParamMap = pageRequestDto.getCustomParamMap();

        // 获取待办分页
        IPage<Tsrevtasklist> page = tsrevtasklistService.todoListWithBizstatu(new Page<>(pageRequestDto.getCurPage(), pageRequestDto.getPageSize()), taskListParam, customParamMap);

        return RestResult.ok(page);
    }
}

