package cn.cslg.pas.controller;


import cn.cslg.pas.common.core.annotation.Permission;
import cn.cslg.pas.common.core.base.Constants;
import cn.cslg.pas.common.model.vo.PatentAnnotationVO;
import cn.cslg.pas.common.utils.auth.checkAuth;
import cn.cslg.pas.service.PatentAnnotationService;
import cn.cslg.pas.common.utils.Response;
import cn.cslg.pas.domain.PatentAnnotation;
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.*;

/**
 * <p>
 * 专利注释 前端控制器
 * </p>
 *
 * @author 王岩
 * @since 2022-03-24
 */
@Tag(name = "专利注释")
@RestController
@RequestMapping(Constants.API_VERSION_V2 + "/patent/annotation")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class PatentAnnotationController {

    private final PatentAnnotationService patentAnnotationService;

    @checkAuth(FunId = "/workspace/details/notes/list")
    @Permission(roles = {1,2,3,4})
    @GetMapping("list")
    @Operation(summary = "注释列表")
    public String getPageList(PatentAnnotationVO params) {
        return Response.success(patentAnnotationService.getPageList(params));
    }

    @checkAuth(FunId = "/workspace/details/notes/add")
    @Permission(roles = {1,2})
    @PostMapping("add")
    @Operation(summary = "添加注释")
    public String add(@RequestBody PatentAnnotation patentAnnotation) {
        return patentAnnotationService.add(patentAnnotation);
    }

    @checkAuth(FunId = "/workspace/details/notes/modify")
    @Permission(roles = {1,2})
    @PostMapping("edit")
    @Operation(summary = "编辑注释")
    public String edit(@RequestBody PatentAnnotation patentAnnotation) {
        return patentAnnotationService.edit(patentAnnotation);
    }

    @checkAuth(FunId = "/workspace/details/notes/delete")
    @Permission(roles = {1,2})
    @PostMapping("delete")
    @Operation(summary = "删除注释")
    public String delete(Integer id) {
        return patentAnnotationService.delete(id);
    }
}