package com.microservices.pms.document.controller;

import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.pms.document.domain.vo.PmsDocumentFavoriteSearchVo;
import com.microservices.pms.document.domain.vo.PmsDocumentVo;
import com.microservices.pms.document.service.IPmsDocumentUserFavoriteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户收藏文档Controller
 * 
 * @author 万佳
 * @date 2024-01-17
 */
@RestController
@RequestMapping("/{enterpriseIdentifier}/documentFavorite")
@Api(tags = "项目管理-知识库收藏接口")
@ApiImplicitParams({
        @ApiImplicitParam(name = "enterpriseIdentifier", value = "企业标识", paramType = "path", dataType = "String")
})
public class PmsDocumentUserFavoriteController extends BaseController
{
    @Autowired
    private IPmsDocumentUserFavoriteService pmsDocumentUserFavoriteService;

    /**
     * 查询用户收藏文档列表
     */
    @GetMapping("/list")
    public GenericsTableDataInfo<PmsDocumentVo> list(PmsDocumentFavoriteSearchVo pmsDocumentFavoriteSearchVo)
    {

        return pmsDocumentUserFavoriteService.selectPmsDocumentUserFavoriteList(pmsDocumentFavoriteSearchVo);
    }

    /**
     * 新增用户收藏文档
     */
    @Log(title = "用户收藏文档", businessType = BusinessType.INSERT)
    @PutMapping("/{documentId}")
    @ApiModelProperty(name = "新增用户收藏文档")
    public AjaxResult add(@PathVariable Long documentId)
    {
        return toAjax(pmsDocumentUserFavoriteService.insertPmsDocumentUserFavorite(documentId));
    }

    /**
     * 删除用户收藏文档
     */
    @Log(title = "用户收藏文档", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentId}")
    @ApiModelProperty(name = "删除用户收藏文档")
    public AjaxResult remove(@PathVariable Long documentId)
    {
        return toAjax(pmsDocumentUserFavoriteService.deletePmsDocumentUserFavoriteByDocId(documentId));
    }
}
