package com.cnooc.expert.controller.portal;

import com.cnooc.expert.common.response.ApiResult;
import com.cnooc.expert.common.response.BasePageResp;
import com.cnooc.expert.controller.portal.model.request.AgentPageReq;
import com.cnooc.expert.controller.portal.model.request.MessagePageReq;
import com.cnooc.expert.controller.portal.model.response.AgentNumResp;
import com.cnooc.expert.controller.portal.model.response.MessageNumResp;
import com.cnooc.expert.service.PortalService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
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;

@AllArgsConstructor
@RestController
@RequestMapping("/portal")
public class PortalController {

    private final PortalService portalService;

    // *** 业务待办 ***

    /**
     * 已办待办数量
     *
     * @return
     */
    @PostMapping("/agent/num")
    public ApiResult<AgentNumResp> agentNum() {
        return ApiResult.successWithResult(portalService.getAgentNum(null));
    }

    /**
     * 已办待办分页列表
     *
     * @return
     */
    @PostMapping("/agent/page")
    public ApiResult<BasePageResp<Object>> agentPage(@RequestBody @Validated AgentPageReq req) {
        int curUserId = 1;
        return ApiResult.successWithResult(portalService.pageAgentNum(req));
    }

    // *** 我的消息 ***

    /**
     * 已读未读数量查询
     *
     * @return
     */
    @PostMapping("/message/num")
    public ApiResult<MessageNumResp> messageNum() {
        return ApiResult.successWithResult(portalService.getMessageNum(null));
    }

    /**
     * 消息列表查询
     *
     * @param req
     * @return
     */
    @PostMapping("/message/page")
    public ApiResult<BasePageResp<Object>> messagePage(@RequestBody @Validated MessagePageReq req) {
        int curUserId = 1;
        return ApiResult.successWithResult(portalService.pageMessageNum(req));
    }

}
