package com.ai.da.controller;

import com.ai.da.common.response.Response;
import com.ai.da.model.dto.ClassificationDTO;
import com.ai.da.model.vo.ClassificationVO;
import com.ai.da.service.ClassificationService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 控制器
 *
 * @author SHAHAIBO
 * @since 2023-11-03
 */
@RestController
@AllArgsConstructor
@NoArgsConstructor
@RequestMapping("/api/classification")
@Api(value = "", tags = "分类")
public class ClassificationController {

    @Resource
    private ClassificationService classificationService;

    /**
     * 新增修改
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增修改", notes = "传入ClassificationDTO")
    public Response<Boolean> saveOrUpdate(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.saveOrUpdate(classificationDTO));
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "删除", notes = "传入ClassificationDTO")
    public Response<Boolean> delete(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.delete(classificationDTO));
    }

    @PostMapping("/queryClassification")
    @ApiOperationSupport(order = 3)
    @ApiModelProperty(value = "查询", notes = "传入ClassificationDTO")
    public Response<List<ClassificationVO>> queryClassification(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.queryClassification(classificationDTO));
    }

    @PostMapping("/relationLibrary")
    @ApiOperationSupport(order = 4)
    @ApiModelProperty(value = "关联", notes = "传入ClassificationDTO")
    public Response<Boolean> relationLibrary(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.relationLibrary(classificationDTO));
    }

    @PostMapping("/getRelClassificationIdList")
    @ApiOperationSupport(order = 5)
    @ApiModelProperty(value = "获取关联分类IDList", notes = "传入ClassificationDTO")
    public Response<List<Long>> getRelClassificationIdList(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.getRelClassificationIdList(classificationDTO));
    }

    /**
     * 多选 获取共有标签
     * @param classificationDTO
     * @return
     */
    @PostMapping("/getRelPublicClassificationIdList")
    @ApiOperationSupport(order = 5)
    @ApiModelProperty(value = "获取关联公共分类IDList", notes = "传入ClassificationDTO")
    public Response<List<Long>> getRelPublicClassificationIdList(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.getRelPublicClassificationIdList(classificationDTO));
    }

    /**
     * 多选 编辑共有标签
     * @param classificationDTO
     * @return
     */
    @PostMapping("/editRelPublicClassificationIdList")
    @ApiOperationSupport(order = 5)
    @ApiModelProperty(value = "编辑关联公共分类IDList", notes = "传入ClassificationDTO")
    public Response<Boolean> editRelPublicClassificationIdList(@Valid @RequestBody ClassificationDTO classificationDTO) {
        return Response.success(classificationService.editRelPublicClassificationIdList(classificationDTO));
    }

}
