package cn.cslg.pas.controller;

import cn.cslg.pas.common.core.base.Constants;
import cn.cslg.pas.common.model.vo.ProjectKeywordVO;
import cn.cslg.pas.common.utils.Response;
import cn.cslg.pas.common.utils.auth.checkAuth;
import cn.cslg.pas.domain.ProjectKeyword;
import cn.cslg.pas.service.ProjectKeywordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 专题库关键词 前端控制器
 * </p>
 *
 * @author 王岩
 * @since 2021-12-24
 */
@Tag(name = "专题库关键词")
@RestController
@RequestMapping(Constants.API_VERSION_V2 + "/project/keyword")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class ProjectKeywordController {

    private final ProjectKeywordService projectKeywordService;

    @GetMapping("list")
    @Operation(summary = "关键词列表")
    public String getPageList(ProjectKeywordVO params) {
        return Response.success(projectKeywordService.getPageList(params));
    }

    @PostMapping("add")
    @Operation(summary = "新增关键词")
    public String add(ProjectKeyword projectKeyword) {
        return projectKeywordService.add(projectKeyword);
    }

    @PostMapping("edit")
    @Operation(summary = "编辑关键词")
    public String edit(ProjectKeyword projectKeyword) {
        return projectKeywordService.edit(projectKeyword);
    }

    @PostMapping("delete")
    @Operation(summary = "删除关键词")
    public String delete(Integer id) {
        return projectKeywordService.delete(id);
    }
}
