package com.ads.business.api;

import com.ads.business.dao.DocRoleDao;
import com.ads.business.service.*;
import com.ads.business.service.model.request.DocListRequest;
import com.ads.common.base.BaseController;
import com.ads.common.data.JsonResult;
import com.ads.common.util.UtilMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 作者 Ludilong
 * @date 创建时间 2021年10月25日
 * @description 文件管理
 */
@Api(tags = "文件管理")
@RestController
@RequestMapping(value = "/api/doc/")
@Slf4j
public class ApiDocController extends BaseController {

    @Resource
    private DocService docService;

    @Resource
    private DocTypeService docTypeService;

    @Resource
    private TypeRoleService typeRoleService;

    @Resource
    private DocTypeConversationRelService docTypeConversationRelService;

    @Resource
    private ConversationUserRelService conversationUserRelService;

    @Resource
    private DocRoleDao docRoleDao;

    @Resource
    private DocConversationRelService docConversationRelService;


    /**
     * 获取文件详情
     *
     * @param docId 文件ID
     * @return 返回结果信息
     */
    @ApiOperation(value = "获取文件详情", notes = "获取文件详情")
    @GetMapping(value = "getDetail")
    public JsonResult getDetail(HttpServletRequest request, @RequestParam(value = "id", required = true) String docId, @RequestParam(value = "userNo", required = true) String userNo) {
        return JsonResult.success(docService.pdfDetail(request, Long.valueOf(docId), userNo), UtilMessage.GET_MESSAGE_SUCCESS);
    }

    /**
     * 获取文件列表信息
     *
     * @param request 参数信息
     * @return 返回文件列表结果
     */
    @ApiOperation(value = "获取文件列表信息", notes = "获取文件列表信息")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK")
    })
    @PostMapping(value = "getDocList")
    public JsonResult getDocList(@RequestBody DocListRequest request) {

        return docService.docList(request, 1);
    }

}
