package com.lz.modules.performance.controller;

import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
import com.lz.modules.performance.req.AssessTaskReq;
import com.lz.modules.performance.res.TaskListRes;
import com.lz.modules.performance.service.AssessService;
import com.lz.modules.sys.controller.AbstractController;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * @Author: djc
 * @Desc:
 * @Date: 2020/10/13 11:27
 */
@RestController
@RequestMapping("/performance")
@Slf4j
@Api(value="事项接口", tags={"用户任务"})
public class UserTaskController extends AbstractController{
    @Autowired
    private AssessService assessService;

    @PostMapping("task/list")
    @ApiOperation("获取待办/处理事项")
    @ApiResponses({@ApiResponse(code = 200,message = "成功",response = TaskListRes.class)})
    public R list(@RequestBody @ApiParam(name = "body",value = "body请求体",required = true) AssessTaskReq req){
        PageUtils pageUtils;
        Long userId = null;
        try {
            userId = getUserId();
            pageUtils = assessService.userTaskList(req, userId);
        } catch (Exception e) {
            log.error("获取用户事项异常 userId:"  + userId,e);
            return R.error(e.getMessage());
        }
        return R.ok().put("data",pageUtils);
    }
}
